package crp.services.api.graphql.models;

import crp.core.space.domain.models.LocationEntity;
import crp.core.space.domain.models.SpaceEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Ignore;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("Space")
@Builder
@Getter
@AllArgsConstructor
public class SpacePayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String name;
    @Ignore
    private final LocationEntity location;

    public static SpacePayload of(SpaceEntity entity) {
        return SpacePayload.builder()
                .id(entity.getId())
                .name(entity.getName())
                .location(entity.getLocation())
                .build();
    }
}
